<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>花间村 - 会员中心 - 收货地址管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <style>
        body { background: #f5f5f5; margin: 0; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; padding-bottom: 60px;}
        .container { max-width: 100%; padding: 15px; }
        .user-card {
            background: #fff;
            border-radius: 12px;
            padding: 15px;
            margin-bottom: 15px;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }
        .user-header {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        .user-avatar {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            margin-right: 15px;
        }
        .user-info h2 {
            margin: 0;
            font-size: 18px;
        }
        .user-info p {
            margin: 5px 0 0;
            color: #666;
            font-size: 14px;
        }
        .page-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; text-align: center; }
        .address-card {
            background: #fff; border-radius: 12px; padding: 15px; margin-bottom: 15px;
            box-shadow: 0 1px 2px rgba(0,0,0,0.07);
            position: relative;
        }
        .address-default { color: #07C160; font-size: 13px; margin-left: 8px; }
        .add-btn {
            display: block; width: 100%; background: #07C160; color: #fff; border: none;
            border-radius: 25px; padding: 12px 0; font-size: 16px; margin-top: 30px; cursor: pointer;
        }
        .address-info { font-size: 16px; margin-bottom: 6px; }
        .address-meta { color: #888; font-size: 14px; }
        .address-actions {
            margin-top: 10px;
            display: flex;
            gap: 10px;
        }
        .edit-btn, .default-btn {
            background: #07C160;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
        }
        .default-btn {
            background: #1890ff;
        }
        .default-tag {
            background: #07C160;
            color: white;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 12px;
            margin-left: 8px;
        }
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 50px;
            background: #fff;
            display: flex;
            justify-content: space-around;
            align-items: center;
            box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
            z-index: 100;
        }
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #666;
            font-size: 12px;
        }
        .nav-item.active {
            color: #07C160;
        }
        .nav-icon {
            font-size: 20px;
            margin-bottom: 2px;
        }
    </style>
</head>
<body>
    <div class="container">

        <div class="user-card">
            <div class="user-header">
                @if(Auth::guard('wechat')->check())
                @php
                $user = Auth::guard('wechat')->user();
                @endphp
                <img src="{{ $user->avatar ?? asset('images/default-avatar.png') }}" class="user-avatar" alt="用户头像">
                <div class="user-info">
                    <h2>{{ $user->nickname ?? $user->name ?? '用户名' }}</h2>
                    <p>{{ $user->province ?? '' }} {{ $user->city ?? '' }}</p>

                </div>
                @else
                <img src="{{ asset('images/default-avatar.png') }}" class="user-avatar" alt="用户头像">
                <div class="user-info">
                    <h2>未登录</h2>
                    <p><a href="{{ route('wechat.service.account.login') }}" style="color: #07C160;">点击登录</a></p>
                </div>
                @endif
            </div>
        </div>

        <div class="page-title">收货地址管理</div>
        @forelse($addresses as $address)
            <div class="address-card">
                <div class="address-info">
                    {{ $address->consignee }} <span class="address-meta">{{ $address->mobile }}</span>
                    @if($address->is_default)
                        <span class="default-tag">默认</span>
                    @endif
                </div>
                <div class="address-meta">
                    {{ $address->province }}{{ $address->city }}{{ $address->district }} {{ $address->address }}
                </div>
                <div class="address-actions">
                    <a href="{{ route('wechat.service.account.addresses.edit', $address->id) }}" class="edit-btn">编辑</a>
                    @if(!$address->is_default)
                    <form method="POST" action="{{ route('wechat.service.account.addresses.set-default', $address->id) }}" style="display: inline;" onsubmit="return confirm('确定要将此地址设为默认地址吗？');">
                        @csrf
                        <button type="submit" class="default-btn">设为默认</button>
                    </form>
                    @endif
                </div>
            </div>
        @empty
            <div style="text-align:center;color:#888;padding:40px 0;">暂无收货地址</div>
        @endforelse

        <a href="{{ route('wechat.service.account.addresses.create') }}">
            <button class="add-btn">+ 添加收货地址</button>
        </a>
    </div>
    @include('wechat.service_account.components.bottom_nav')
</body>
</html>